// Package App.admin contains basic admin actions
package admin

import (
	"git.oschina.net/fuxiaohei/fuxiaohei-go.git/Core"
)

// Home struct
type Home struct {

}

// Setup
func (_ Home) Setup() {
	Core.SetRoute("GET:/admin", "[I]admin.Home.MainAction")
	Core.SetRoute("GET:/admin/home", "[I]admin.Home.HomeAction")
	Core.SetRoute("GET:/admin/extends", "[I]admin.Home.ExtendAction")
}

// admin/home page
func (_ Home) HomeAction(request *Core.HxRequest, response *Core.HxResponse) {
	if !LoginCheck(request) {
		LoginDestroy(response)
		return
	}
	response.Body = RenderAdminPage("home.html", nil, nil, "")
}

func (_ Home) MainAction(request *Core.HxRequest, response *Core.HxResponse) {
	if !LoginCheck(request) {
		LoginDestroy(response)
		return
	}
	response.Redirect("/admin/home/")
}

func (_ Home) ExtendAction(request *Core.HxRequest, response *Core.HxResponse) {
	if !LoginCheck(request) {
		LoginDestroy(response)
		return
	}
	response.Body = RenderAdminPage("extend.html", nil, nil, "extend")
}

